<include file="../Public/agent.header.html" />
<link href="__PUBLIC__/Css/user.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/Js/user/common.js" charset="UTF-8"></script>
<script type="text/javascript" src="__PUBLIC__/Js/jquery.form.js"></script>
<link href="__PUBLIC__/Js/setavatar/css/imgareaselect-default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/Js/avatar/avatar.js"></script>
<script type="text/javascript" src="__PUBLIC__/Js/setavatar/jquery.imgareaselect.min.js"></script>
<script>
$(function(){
	$('#agent_form').submit(function(){
		var title_ 		=$('#agent_form').find('#title').val();
		var site_url_	=$('#agent_form').find('#site_url').val();
		var contact_	=$('#agent_form').find('#contact').val();
		var phone_		=$('#agent_form').find('#phone').val();
		var bank_name_	=$('#agent_form').find('#bank_name').val();
		var bank_user_	=$('#agent_form').find('#bank_user').val();
		var bank_no_	=$('#agent_form').find('#bank_no').val();
		var ifcansubmit = true;
		if(title_==''){ $('#agent_form').find('#title').addClass('_tmp_border_red');ifcansubmit=false;}else{ $('#agent_form').find('#title').removeClass('_tmp_border_red');}
		if(site_url_==''){ $('#agent_form').find('#site_url').addClass('_tmp_border_red');ifcansubmit=false;}else{ $('#agent_form').find('#site_url').removeClass('_tmp_border_red');}
		if(contact_==''){ $('#agent_form').find('#contact').addClass('_tmp_border_red');ifcansubmit=false;}else{ $('#agent_form').find('#contact').removeClass('_tmp_border_red');}
		if(phone_==''){ $('#agent_form').find('#phone').addClass('_tmp_border_red');ifcansubmit=false;}else{ $('#agent_form').find('#phone').removeClass('_tmp_border_red');}
		if(bank_name_==''){ $('#agent_form').find('#bank_name').addClass('_tmp_border_red');ifcansubmit=false;}else{ $('#agent_form').find('#bank_name').removeClass('_tmp_border_red');}
		if(bank_user_==''){ $('#agent_form').find('#bank_user').addClass('_tmp_border_red');ifcansubmit=false;}else{ $('#agent_form').find('#bank_user').removeClass('_tmp_border_red');}
		if(bank_no_==''){ $('#agent_form').find('#bank_no').addClass('_tmp_border_red');ifcansubmit=false;}else{ $('#agent_form').find('#bank_no').removeClass('_tmp_border_red');}
		if(!ifcansubmit){
			ui.error('信息录入错误，请检查');
			return false;
		}

		var defaults = {
				ajx_rtn_type:'JSON',//HTML JSON
				type:"post",
				success:function(txt){
					alert(txt);
					txt = eval('(' + txt + ')');
					if(txt.status==1){
						ui.success(txt.msg);
						windowreload();
					}else{
						ui.error(txt.msg);
					}
				},//如果为json则将解析好的json对象作为参数调用success。
				error:null
				};
		$(this).ajaxSubmit(defaults);
		return false;
		
	});
});
</script>

<style>
.data {
    margin-left: 20px;
    overflow: hidden;
    width: 720px;
}
.data ul li .areal {
    width: 15%;
}
.data ul li .area2 {
    width: 85%;
}
.data ul li .area2 .alert_desc {
    color: #999999;
    font-size: 12px;
    line-height: 30px;
    padding-left: 15px;
}
._tmp_border_red{
	border: 1px solid red;
}
</style>
<div id="mainWrapper">

<div id="main">
 	<include file="../agent/Tpl/default/Public/user_left_nav_box.html" />
    
    <div id="right_box">
				<div class="item_top">
					<ul>
						<li class="top_bar top-bar-wide top_baron">{$userNavDict[MODULE_NAME][ACTION_NAME]}</li>
					</ul>
				</div>
				
				<div class="feedBox">
							
							<!-- 修改密码 -->
		          <div class="setItems">
		          	<div class="setFold setUnfold" rel="userinfo" >
		              <h2>会员信息</h2>
		            </div>
		            <div style="display: block;" class="setItemsInfo">
			            <div class="k_desc_div" style="margin: 1px;">
							<div class="k_icon k_bulb"></div>
							<strong>提示</strong>
							<div>
							请正确填写会员信息，一旦审核通过银行账号不允许在线修改。
							<br>若需修改请下载打印“银行账号申请单修改”，填写相关信息后邮递给我们。						
							</div>
						</div>	
						<div class="clear"></div>
		            	<form action="{:U('agent://Account/saveProfile')}" method="post" id="agent_form">
							      <div class="data">
							            <ul>
							            	<li>
							                    <div class="left alR input_title areal">注册邮箱：</div>
							                    <div class="left area2">
							                    <div class="left mr5" style=" font-size: 16px;">{$userInfo['email']}</div>
							                    <div class="left mr5 alert_desc">注册邮箱，用于登录。</div>
							                    </div>
							                </li>
							                <li>
							                    <div class="left alR input_title areal">网站名称：</div>
							                    <div class="left area2">
							                      	<div class="left mr5">
							                      		<input id="title" name="title" type="text" value="{$agentInfo['title']}" class="input_text" 
							                      			<php>if($agentstatus['status']==1){</php>readonly style="background:#EEEEEE;"<php>}</php> /></div>
							                    	<div class="left mr5 alert_desc">必填项，您的网站名称。如：小心意</div>
							                    </div>
							                </li>
							                <li>
							                    <div class="left alR input_title areal">网站网址：</div>
							                   	<div class="left area2">
							                      	<div class="left mr5">
							                      		<input id="site_url" name="site_url" type="text" value="{$agentInfo['site_url']}" class="input_text" 
							                      			<php>if($agentstatus['status']==1){</php>readonly style="background:#EEEEEE;"<php>}</php> /></div>
							                    	<div class="left mr5 alert_desc">必填项，您的网站网址。如：www.xiaoxinyi.com</div>
							                    </div>
							                </li>
							                <li>
							                    <div class="left alR input_title areal">联系人名：</div>
							                    <div class="left area2">
							                      	<div class="left mr5">
							                      		<input id="contact" name="contact" type="text" value="{$agentInfo['contact']}" class="input_text" 
							                      			<php>if($agentstatus['status']==1){</php>readonly style="background:#EEEEEE;"<php>}</php> /></div>
							                    	<div class="left mr5 alert_desc">必填项，联系人名。提交申请后我们会电话联系以便确认。</div>
							                    </div>
							                </li>
							                <li>
							                    <div class="left alR input_title areal">联系电话：</div>
							                   	<div class="left area2">
							                      	<div class="left mr5">
							                      		<input id="phone" name="phone" type="text" value="{$agentInfo['phone']}" class="input_text" 
							                      			<php>if($agentstatus['status']==1){</php>readonly style="background:#EEEEEE;"<php>}</php> /></div>
							                    	<div class="left mr5 alert_desc">必填项，联系电话。提交申请后我们会电话联系以便确认。</div>
							                    </div>
							                </li>
							                
							                <li>
							                    <div class="left alR input_title areal">开户银行：</div>
							                    <div class="left area2">
							                      	<div class="left mr5">
							                      		<input id="bank_name" name="bank_name" title="录入开户银行名称" type="text" value="{$agentInfo['bank_name']}" class="input_text" 
							                      			<php>if($agentstatus['status']==1){</php>readonly style="background:#EEEEEE;"<php>}</php> /></div>
							                    	<div class="left mr5 alert_desc">必填项，订单分成收益汇入账户的开户银行名称。</div>
							                    </div>
							                </li>
							                
							                <li>
							                    <div class="left alR input_title areal">开户名称：</div>
							                    <div class="left area2">
							                      	<div class="left mr5">
							                      		<input id="bank_user" title="录入银行账号对应的用户名称" name="bank_user" type="text" value="{$agentInfo['bank_user']}" class="input_text" 
							                      			<php>if($agentstatus['status']==1){</php>readonly style="background:#EEEEEE;"<php>}</php> /></div>
							                    	<div class="left mr5 alert_desc">必填项，订单分成收益汇入账户的开户者名称。</div>
							                    </div>
							                </li>
							                
							                <li>
							                    <div class="left alR input_title areal">汇款账号：</div>
							                    <div class="left area2">
							                      	<div class="left mr5">
							                      		<input id="bank_no" name="bank_no" title="录入银行账号" type="text" value="{$agentInfo['bank_no']}" class="input_text" 
							                      			<php>if($agentstatus['status']==1){</php>readonly style="background:#EEEEEE;"<php>}</php> /></div>
							                    	<div class="left mr5 alert_desc">必填项，订单分成收益汇入账户。</div>
							                    </div>
							                </li>
							                
							                <li>
							                	<div class="left alR areal">&nbsp;</div>
							                	<div class="left area2">
							                	<php>if($agentstatus['status']==1){</php>
							                		申请已通过，不能修改！如需修改请先<a href="">撤销申请</a>！
							                	<php>}else if($agentstatus['status']==-1){</php>
							                		<input type="submit" class="btn_r" value="重新申请" id="btn_modify_pwd"/>
							                	<php>}else if($agentstatus['status']==0){</php>
							                		<input type="submit" class="btn_r" value="提交申请" id="btn_modify_pwd"/>
							                	<php>}</php>
							                	</div>
							                </li>
							           </ul>
							      </div>
							</form>
						</div>
					</div><!-- 修改密码 end  -->
		
							<!-- 修改交易密码 -->
		          	<div class="setItems">
			            <div class="setFold setUnfold" rel="avatar" style="padding: 0px 0px;">
			            	<div style="width: 34px; margin: 4px 10px; float: left;">
				            	<div style="float:left;margin-right:10px;border:1px solid #8098A8;height:30px;padding:1px;width:30px;">
				            		<img src="{$mid|getUserFace='s'}" width="30">
				            	</div>
			            	</div>
				            <div style="margin:auto;padding: 8px 15px;">
				              <h2>网站LOGO&nbsp;&nbsp;&nbsp;
				              	<span class="setStep">
										  	<font class="txt1" id="avatarInfo">
												<php>if( isSetAvatar($mid) ){</php>
													已设置LOGO
												<php>}else{</php>
													未设置LOGO
												<php>}</php>
												</font>
												</span>
				              	
				              </h2>
				            </div>
			            </div>
			            <div style="display: block;" class="setItemsInfo">
			            	<div style="margin:0px 60px;">
												<div style="padding:10px 0;color:#666;"> 
													<form enctype="multipart/form-data" method="post" id="uploadpic" name="upform" dotype="ajax" callback="uploadpic" target="upload_target" action="{:U('agent://Account/avatar',array('t'=>'upload'))}">
														<input type="file" name="Filedata" onchange="douploadpic()" id="Filedata" style="height:23px"/> 
														<span style="display:none;" id="loading_gif"><img src="__PUBLIC__/Js/avatar/loading.gif" align="absmiddle" />上传中，请稍侯......</span>  
													</form>
												</div> 
					              <div class="picSettings">
					                <div id="photo" class="left" style="width:400px; height:300px; border-right:1px solid #E5E5E5">
													</div>
					                <div class="left" style="width:200px; padding-left:15px;">
					                   <div style="width:180px;  margin-bottom:20px; font-size:16px"><strong>LOGO预览</strong></div>
					                   <div class="left" style=" width: 150px; height: 150px; border:1px solid #B4B5AF;overflow: hidden;"><img id="photo_big" src="{$mid|getUserFace='b'}" /></div>
									</div>
													<form enctype="multipart/form-data" method="post" id='upform' name="upform" dotype="ajax" callback="dosaveface" target="_blank" action="{:U('agent://Account/avatar',array('t'=>'save'))}">
														<input type="hidden" name="picurl">
														<input type="hidden" name="x1">
														<input type="hidden" name="y1">
														<input type="hidden" name="x2">
														<input type="hidden" name="y2">
														<input type="hidden" name="w">
														<input type="hidden" name="h">
														<div style="clear:left; padding-top:20px;padding-left:100px;"> <input type="submit" class="btn_o" value="确定" /> <input type="button" class="btn_w" value="取消" onclick="unSetFace()" /></div>
													</form>
                				</div>
                			</div>
						</div>
			        </div><!-- 修改交易密码 end  -->
							
		          
		        <div class="c"></div>
		        </div>
		      </div>
  <!-- 右侧内容 end  -->
  <div class="c"></div>
</div>
</div>
<include file="../Public/footer.html" />
	
	
<script type="text/javascript">
	//$(document).ready(function(){
		var hs = document.location.hash;
		var up_pic_width =50;
		var up_pic_height =50;
		var _basemodel = 'userinfo';
		changeModel( hs.replace('#',''),_basemodel );
		$('.setFold').click(function(){
			if( $(this).attr('class')=='setFold' ){
				changeModel( $(this).attr('rel'),_basemodel );
			}else{
				$(this).removeClass('setUnfold');
				$(this).next('.setItemsInfo').hide();
			}
			location.href='#'+$(this).attr('rel');
		});
		_tmp_initForm('uploadpic');
		_tmp_initForm('upform');
	//});
	
	
	function _tmp_initForm(formid){
		//监听 form 表单提交
	  	$("#"+formid).bind('submit', function() {
						var callbackfun = $(this).attr('callback');
						var type   = $(this).attr('type');
						var options = {
						    success: function(txt) {
						    	//alert(txt);
						    	txt = eval("("+txt+")");
									if(callbackfun){
										callback(eval(callbackfun),txt);
									}else{
										  if(txt.boolen){
											  ui.success( txt.message );
										  }else{
											  ui.error( txt.message );
										  }
										  	 
									}
						    }
						};		
	          $(this).ajaxSubmit(options);
			 			return false;
	    });
	}
	
	function callback(fun,argum){
		fun(argum);
	}
	
	function dosaveface(txt){
		if (txt=='-1') {
			ui.error('更新失败');
		}else {
			alert('更新成功');
	        location.reload();
		}
	}
	
	function douploadpic(){
			//alert('111');
			$('#loading_gif').show();
			$('input[name="Filedata"]').hide();
			var options = {
				    success: function(txt) {
							uploadpic(txt);
				    }
			};		
			$('#uploadpic').ajaxSubmit(options);
		  return false;		
	}
	var imgrs;
	function uploadpic(txt){
		txt = eval('('+txt+')');
		if(txt.code==1){
			var tmpDate = new Date(); 
			set_UP_W_H(txt.data['picwidth'],txt.data['picheight']);
			var defautlv = ( txt.data['picwidth'] > txt.data['picheight']) ?txt.data['picheight']:txt.data['picwidth'];
	//		$("#photo").attr('src',txt.data['picurl']+'?t='+ tmpDate.getTime());
			$("#photo").html("<img id='photo_img' src="+txt.data['picurl']+'?t='+ tmpDate.getTime()+">");
			$("input[name=picurl]").attr('value',txt.data['picurl']);
		 	$("#photo_big").attr('src',txt.data['picurl']+'?t='+ tmpDate.getTime());
		
		 	imgrs = $('#photo_img').imgAreaSelect({ 
						x1: 0, 
						y1: 0,
					    x2: 100, 
						y2: 100, 
						handles: true,
						onInit:preview,
						onSelectChange:preview,
						onSelectEnd:onSelectEnd,
						aspectRatio: '1:1',
						instance: true,
						parent:$('#photo')
						});
			$('#loading_gif').hide();
		 }else{
		 	alert(txt.message);
		 }
	}
	
	//重新上传图片
	function unSetFace(){
		var defaultpic = "{$mid|getUserFace=b}"
		$('input[name="Filedata"]').show();
		$("#photo").html("");
		$("input[name=picurl]").attr('value','');
	 	$("#photo_big").attr('src',defaultpic);
	 	$('#photo_big').attr('style','position: relative;');
	 	imgrs.setOptions({ remove:true });
	 	imgrs.update();
	};	
	
	function set_UP_W_H(w,h){
		up_pic_width = w;
		up_pic_height = h;
	}	
		
	function onSelectEnd(img,selection){
	    $('input[name=x1]').val(selection.x1);
	    $('input[name=y1]').val(selection.y1);
	    $('input[name=x2]').val(selection.x2);
	    $('input[name=y2]').val(selection.y2); 
	    $('input[name=w]').val(selection.width); 
	    $('input[name=h]').val(selection.height); 
	}
		
	function preview(img, selection) {
		onSelectEnd(img,selection);
		var big_scaleX = 150 / (selection.width || 1);
	    var big_scaleY = 150 / (selection.height || 1);
		
	    $('#photo_big').css({
	        width: Math.round(big_scaleX * up_pic_width) + 'px',
	        height: Math.round(big_scaleY * up_pic_height) + 'px',
	        marginLeft: '-' + Math.round(big_scaleX * selection.x1) + 'px',
	        marginTop: '-' + Math.round(big_scaleY * selection.y1) + 'px'
	    });
	}		
	
	
</script>